Page({
    data: {
        skins: [] as HeroSkin[],
        activeIndex: 0
    },
    //轮播图绑定事件
    onswiperChange(event: WechatMiniprogram.SwiperChange) {
        this.setData({
            activeIndex: event.detail.current
        })
    },
    onLoad(options) {
        console.log(options)
        if (options.id) {
            this.getDetail(options.id)
        }
    },
    getDetail(id: string) {
        return new Promise((resolve) => {
            wx.request<ServerResponse<HeroData>>({
                method: 'GET',
                url: 'https://api-vue-base.itheima.net/api/lol/info',
                data: {
                    id: id
                },
                success: (res) => {
                    resolve(res.data.data)
                    this.setData({
                        skins: res.data.data.skins
                    });
                    wx.setNavigationBarTitle({
                        title:res.data.data.hero.title
                    })
                },
                
            })
        })

    },

})